package com.jrx.anytxn.transaction.bean;

import com.jrx.anytxn.transaction.entity.*;
import org.apache.commons.collections.CollectionUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: anytxn-cf-transaction
 * @description: 保存本金利息罚息dto对象
 * @author: xiaoyu.jing
 * @date: 2019-10-14 17:49
 **/
public class PaymentSaveBean {

    private List<AmLoanMainInfo> amLoanMainInfoList = new ArrayList<>();//原订单信息账户;

    private TlPaymentAllocationLog savaPaymentLog;//需要保存的还款总交易账户

    private Map<Integer, AmRepaymentPlanInfo> planInfoMap;//还款分配需要处理的还款计划，按期分组

    private Map<Integer, AmWaiveRepaymentPlanInfo> waivePlanInfoMap;//还款分配需要处理的还款计划，按期分组

    private Map<String,Map<Integer, AmRepaymentPlanInfo>> planInfoAllMap= new HashMap<>();//所有还款分配需要处理的还款计划，每一个先按订单分组，再按期分组

    private List<AmAccountMainInfo> saveAcctList = new ArrayList<>();//需要保存的交易账户

    private List<AmAccountMainInfo> updateAcctList = new ArrayList<>();//需要更新的交易账户

    private List<AmInterestAccrualInfo> saveAccuAcctList = new ArrayList<>();//需要保存的累计账户

    private List<AmInterestAccrualInfo> updateAccuAcctList = new ArrayList<>();//需要更新的累计账户

    private List<TlPaymentAllocationLog> paymentLogSaveList = new ArrayList<>();//需要保存的还款子交易账户

    private List<TlGlInterfaceInfo> saveGlList = new ArrayList<>();//需要保存的gl流水

    private List<AmRepaymentPlanInfo> updatePlanList = new ArrayList<>();//需要更新的还款计划

    private List<AmRepaymentPlanInfo> savePlanList = new ArrayList<>();//需要保存的还款计划

    private List<AmDelinquencyInfo> updateDelqList = new ArrayList<>();////需要更新的延滞交易账户

    private AmLoanAccountInfo updateLoan;//需要更新的订单

    private List<AmLoanAccountInfo> updateLoanList = new ArrayList<>();//需要更新的订单

    private List<AmAccountMainInfo> allAcctList = new ArrayList<>();//需要更新和保存的所有交易账户

    private List<AmAccountMainInfo> needDealAcctList = new ArrayList<>();//所有需要处理的交易账户

    private List<TlTransactionInfo> transactionInfoList = new ArrayList<>();//交易信息

    private List<TlWaivePaymentLog> tlWaivePaymentLogList = new ArrayList<>();

    private List<BtAccountingTransferList> transferLists = new ArrayList<>();

    private List<AmWaiveRepaymentPlanInfo> saveWaivePlanList = new ArrayList<>();//需要保存的还款计划

    private List<AmWaiveRepaymentPlanInfo> updateWaivePlanList = new ArrayList<>();

    private List<TlLoanClassifyChange> saveClassifyList = new ArrayList<>();//结清需要保存五级分类

    public TlPaymentAllocationLog getSavaPaymentLog() {
        return savaPaymentLog;
    }

    public List<TlWaivePaymentLog> getTlWaivePaymentLogList() {
        return tlWaivePaymentLogList;
    }

    public void setTlWaivePaymentLogList(List<TlWaivePaymentLog> tlWaivePaymentLogList) {
        this.tlWaivePaymentLogList = tlWaivePaymentLogList;
    }

    public void setPaymentLogSaveList(List<TlPaymentAllocationLog> paymentLogSaveList) {
        this.paymentLogSaveList = paymentLogSaveList;
    }

    public List<TlWaivePaymentMapping> getTlWaivePaymentMappingList() {
        return tlWaivePaymentMappingList;
    }

    public void setTlWaivePaymentMappingList(List<TlWaivePaymentMapping> tlWaivePaymentMappingList) {
        this.tlWaivePaymentMappingList = tlWaivePaymentMappingList;
    }

    private List<TlWaivePaymentMapping> tlWaivePaymentMappingList = new ArrayList<>();

    public List<BtAccountingTransferList> getTransferLists() {
        return transferLists;
    }

    public void addTransferList(BtAccountingTransferList transferList) {
        if (null != transferList) {
            this.transferLists.add(transferList);
        }
    }

    public void addTransferLists(List<BtAccountingTransferList> transferLists) {
        if (CollectionUtils.isNotEmpty(transferLists)) {
            this.transferLists.addAll(transferLists);
        }
    }

    public void setSavaPaymentLog(TlPaymentAllocationLog savaPaymentLog) {
        this.savaPaymentLog = savaPaymentLog;
    }

    public List<AmAccountMainInfo> getNeedDealAcctList() {
        if (CollectionUtils.isNotEmpty(needDealAcctList)) {
            needDealAcctList.clear();
        }

        needDealAcctList.addAll(saveAcctList);
        needDealAcctList.addAll(updateAcctList);

        return needDealAcctList;
    }

    public List<AmAccountMainInfo> getAllAcctList() {
        return allAcctList;
    }

    public void setAllAcctList(List<AmAccountMainInfo> allAcctList) {
        this.allAcctList = allAcctList;
    }

    public List<TlPaymentAllocationLog> getPaymentLogSaveList() {
        return paymentLogSaveList;
    }

    public void addPaymentLog(TlPaymentAllocationLog paymentLog) {
        if (null != paymentLog) {
            this.paymentLogSaveList.add(paymentLog);
        }
    }

    public void addPaymentLogList(List<TlPaymentAllocationLog> paymentLogList) {
        if (CollectionUtils.isNotEmpty(paymentLogList)) {
            this.paymentLogSaveList.addAll(paymentLogList);
        }
    }

    public List<AmRepaymentPlanInfo> getUpdatePlanList() {
        return updatePlanList;
    }

    public void addUpdatePlan(AmRepaymentPlanInfo updatePlan) {
        if (null != updatePlan) {
            this.updatePlanList.add(updatePlan);
        }
    }

    private void addUpdatePlanList(List<AmRepaymentPlanInfo> updatePlanList) {
        if (CollectionUtils.isNotEmpty(updatePlanList)) {
            this.updatePlanList.addAll(updatePlanList);
        }
    }

    public List<AmDelinquencyInfo> getUpdateDelqList() {
        return updateDelqList;
    }

    public void addUpdateDelq(AmDelinquencyInfo delq) {
        if (null != delq) {
            this.updateDelqList.add(delq);
        }
    }

    private void addUpdateDelqList(List<AmDelinquencyInfo> updateDelqList) {
        if (CollectionUtils.isNotEmpty(updateDelqList)) {
            this.updateDelqList.addAll(updateDelqList);
        }
    }

    public AmLoanAccountInfo getUpdateLoan() {
        return updateLoan;
    }

    public void setUpdateLoan(AmLoanAccountInfo updateLoan) {
        this.updateLoan = updateLoan;
    }

    public List<AmLoanAccountInfo> getUpdateLoanList() {
        return updateLoanList;
    }

    public Map<Integer, AmRepaymentPlanInfo> getPlanInfoMap() {
        return planInfoMap;
    }

    public void setPlanInfoMap(Map<Integer, AmRepaymentPlanInfo> planInfoMap) {
        this.planInfoMap = planInfoMap;
    }

    public List<TlGlInterfaceInfo> getSaveGlList() {
        return saveGlList;
    }

    public List<AmRepaymentPlanInfo> getSavePlanList() {
        return savePlanList;
    }

    public void addSavePlan(AmRepaymentPlanInfo plan) {
        if (null != plan) {
            this.savePlanList.add(plan);
        }
    }

    private void addSavePlanList(List<AmRepaymentPlanInfo> savePlanList) {
        if (CollectionUtils.isNotEmpty(savePlanList)) {
            this.savePlanList.addAll(savePlanList);
        }
    }

    public List<AmAccountMainInfo> getSaveAcctList() {
        return saveAcctList;
    }

    public void addSaveAcct(AmAccountMainInfo saveAcct) {
        if (null != saveAcct) {
            this.saveAcctList.add(saveAcct);
        }
    }

    public void setSaveAcctList(List<AmAccountMainInfo> saveAcctList) {
        this.saveAcctList = saveAcctList;
    }

    public void addSaveAcctList(List<AmAccountMainInfo> saveAcctList) {
        if (CollectionUtils.isNotEmpty(saveAcctList)) {
            this.saveAcctList.addAll(saveAcctList);
        }
    }

    public List<AmAccountMainInfo> getUpdateAcctList() {
        return updateAcctList;
    }

    public void setUpdateAcctList(List<AmAccountMainInfo> updateAcctList) {
        this.updateAcctList = updateAcctList;
    }

    public void addUpdateAcct(AmAccountMainInfo updateAcct) {
        if (null != updateAcctList) {
            this.updateAcctList.add(updateAcct);
        }
    }

    private void addUpdateAcctList(List<AmAccountMainInfo> updateAcctList) {
        if (CollectionUtils.isNotEmpty(updateAcctList)) {
            this.updateAcctList.addAll(updateAcctList);
        }
    }


    public List<AmInterestAccrualInfo> getSaveAccuAcctList() {
        return saveAccuAcctList;
    }

    private void addUpdateAccuAcctList(List<AmInterestAccrualInfo> updateAccuAcctList) {
        if (CollectionUtils.isNotEmpty(updateAccuAcctList)) {
            this.updateAccuAcctList.addAll(updateAccuAcctList);
        }
    }

    public void addSaveAccuAcctList(List<AmInterestAccrualInfo> saveAccuAcctList) {
        if (CollectionUtils.isNotEmpty(saveAccuAcctList)) {
            this.saveAccuAcctList.addAll(saveAccuAcctList);
        }
    }

    public List<AmInterestAccrualInfo> getUpdateAccuAcctList() {
        return updateAccuAcctList;
    }

    public void addUpdateAccuAcct(AmInterestAccrualInfo amInterestAccrualInfo) {
        if (null != amInterestAccrualInfo) {
            this.updateAccuAcctList.add(amInterestAccrualInfo);
        }
    }

    public List<TlTransactionInfo> getTransactionInfoList() {
        return transactionInfoList;
    }

    public void addTransactionInfo(TlTransactionInfo transactionInfo) {
        if (null != transactionInfo) {
            this.transactionInfoList.add(transactionInfo);
        }
    }

    public void addTransactionInfoList(List<TlTransactionInfo> transactionInfoList) {
        if (CollectionUtils.isNotEmpty(transactionInfoList)) {
            this.transactionInfoList.addAll(transactionInfoList);
        }
    }

    public void addSaveGlList(List<TlGlInterfaceInfo> saveGlList) {
        if (CollectionUtils.isNotEmpty(saveGlList)) {
            this.saveGlList.addAll(saveGlList);
        }
    }

    public void addSaveGl(TlGlInterfaceInfo gl) {
        if (null != gl) {
            this.saveGlList.add(gl);
        }
    }

    public Map<String, Map<Integer, AmRepaymentPlanInfo>> getPlanInfoAllMap() {
        return planInfoAllMap;
    }

    public void setPlanInfoAllMap(Map<String, Map<Integer, AmRepaymentPlanInfo>> planInfoAllMap) {
        this.planInfoAllMap = planInfoAllMap;
    }

    public void addUpdateLoan(AmLoanAccountInfo updateLoan) {
        if (null != updateLoan) {
            this.updateLoanList.add(updateLoan);
        }
    }

    public void setSaveAccuAcctList(List<AmInterestAccrualInfo> saveAccuAcctList) {
        this.saveAccuAcctList = saveAccuAcctList;
    }

    public void setUpdateAccuAcctList(List<AmInterestAccrualInfo> updateAccuAcctList) {
        this.updateAccuAcctList = updateAccuAcctList;
    }

    public void setTransactionInfoList(List<TlTransactionInfo> transactionInfoList) {
        this.transactionInfoList = transactionInfoList;
    }

    public void setSaveGlList(List<TlGlInterfaceInfo> saveGlList) {
        this.saveGlList = saveGlList;
    }

    public Map<Integer, AmWaiveRepaymentPlanInfo> getWaivePlanInfoMap() {
        return waivePlanInfoMap;
    }

    public void setWaivePlanInfoMap(Map<Integer, AmWaiveRepaymentPlanInfo> waivePlanInfoMap) {
        this.waivePlanInfoMap = waivePlanInfoMap;
    }

    public List<AmWaiveRepaymentPlanInfo> getUpdateWaivePlanList() {
        return updateWaivePlanList;
    }

    public void setUpdateWaivePlanList(List<AmWaiveRepaymentPlanInfo> updateWaivePlanList) {
        this.updateWaivePlanList = updateWaivePlanList;
    }

    public List<AmWaiveRepaymentPlanInfo> getSaveWaivePlanList() {
        return saveWaivePlanList;
    }

    public void setSaveWaivePlanList(List<AmWaiveRepaymentPlanInfo> saveWaivePlanList) {
        this.saveWaivePlanList = saveWaivePlanList;
    }

    public List<TlLoanClassifyChange> getSaveClassifyList() {
        return saveClassifyList;
    }

    public void setSaveClassifyList(List<TlLoanClassifyChange> saveClassifyList) {
        this.saveClassifyList = saveClassifyList;
    }

    public List<AmLoanMainInfo> getAmLoanMainInfoList() {
        return amLoanMainInfoList;
    }

    public void setAmLoanMainInfoList(List<AmLoanMainInfo> amLoanMainInfoList) {
        this.amLoanMainInfoList = amLoanMainInfoList;
    }

    public void addAmLoanMainInfo(AmLoanMainInfo amLoanMainInfo) {
        this.amLoanMainInfoList.add(amLoanMainInfo);
    }

    public void addUpdateLoanList(List<AmLoanAccountInfo> updateLoanList) {
        if (CollectionUtils.isNotEmpty(updateLoanList)) {
            this.updateLoanList.addAll(updateLoanList);
        }
    }


    /**
     * saveBean合并方法
     *
     * @param orgiSaveBean
     * @return
     */
    public PaymentSaveBean add(PaymentSaveBean orgiSaveBean) {
        this.setSavaPaymentLog(orgiSaveBean.getSavaPaymentLog());
        this.addPaymentLogList(orgiSaveBean.getPaymentLogSaveList());
        this.addSaveAccuAcctList(orgiSaveBean.getSaveAccuAcctList());
        this.addUpdateAccuAcctList(orgiSaveBean.getUpdateAccuAcctList());
        this.addSaveAcctList(orgiSaveBean.getSaveAcctList());
        this.addUpdateAcctList(orgiSaveBean.getUpdateAcctList());
        this.addSaveGlList(orgiSaveBean.getSaveGlList());
        this.addSavePlanList(orgiSaveBean.getSavePlanList());
        this.addUpdatePlanList(orgiSaveBean.getUpdatePlanList());
        this.addUpdateDelqList(orgiSaveBean.getUpdateDelqList());
        this.addTransactionInfoList(orgiSaveBean.getTransactionInfoList());
        this.addUpdateLoanList(orgiSaveBean.getUpdateLoanList());
        this.addUpdateLoan(orgiSaveBean.getUpdateLoan());
        this.addTransferLists(orgiSaveBean.getTransferLists());
        this.getTlWaivePaymentLogList().addAll(orgiSaveBean.getTlWaivePaymentLogList());
        this.getTlWaivePaymentMappingList().addAll(orgiSaveBean.getTlWaivePaymentMappingList());
        this.getUpdateWaivePlanList().addAll(orgiSaveBean.getUpdateWaivePlanList());
        this.getSaveWaivePlanList().addAll(orgiSaveBean.getSaveWaivePlanList());
        this.getSaveClassifyList().addAll(orgiSaveBean.getSaveClassifyList());
        this.getAmLoanMainInfoList().addAll(orgiSaveBean.getAmLoanMainInfoList());
        return this;
    }
}
